    #include "Date.h"
    bool Date::checkDate() const
    {
        if(_month < 1 || _month > 12) {
            return false;
        }
        if(_day < 0 || _day > getMonthDay(_year, _month)) {
            return false;
        }
        return true;
    }
    ostream &operator<<(ostream &out, const Date &d)
    {
        out << d._year << "/" << d._month << "/" << d._day << endl;
        return out;
    }
    istream &operator>>(istream &in, Date &d)
    {
        cout << "请输入要操作的数：";
        in >> d._year >> d._month >> d._day;
        while(!d.checkDate()) {
            cout << "请重新输入要操作的数：";
            in >> d._year >> d._month >> d._day;
        }
        return in;
    }
    Date::Date(int year, int month, int day)
    {
        _year = year;
        _month = month;
        _day = day;
    }
    void Date::Print() const
    {
        cout << _year << "/" << _month << "/" << _day << endl;
    }
    bool Date::operator<(const Date &d) const
    {
        if (_year != d._year)
            return _year < d._year;
        if (_month != d._month)
            return _month < d._month;
        return _day < d._day;
    }
    bool Date::operator<=(const Date &d) const
    {
        return *this < d || *this == d;
    }
    bool Date::operator>(const Date &d) const
    {
        if (_year != d._year)
            return _year > d._year;
        if (_month != d._month)
            return _month > d._month;
        return _day > d._day;
    }
    bool Date::operator>=(const Date &d) const
    {
        return *this > d || *this == d;
    }
    bool Date::operator==(const Date &d) const
    {
        return _year == d._year && _month == d._month && _day == d._day;
    }
    bool Date::operator!=(const Date &d) const
    {
        return !(*this == d);
    }
    Date Date::operator+(int day) const
    {   
        Date temp = *this;
        temp += day;
        return temp;
    }
    Date& Date::operator+=(int day)
    {
        while(_day + day > getMonthDay(_year, _month)) {
            day -= getMonthDay(_year, _month);
            _month++;
            if(_month > 12) {
                _year++;
                _month = 1;
            }
        }
        _day = _day + day;
        return *this;
    }
    Date Date::operator-(int day) const
    {
        Date temp = *this;
        temp -= day;
        return temp;
    }
    Date& Date::operator-=(int day)
    {
        while(_day - day < 0) {
            _month--;
            if(_month < 1) {
                _month = 12;
                _year--;
            }
            _day += getMonthDay(_year, _month);   
        }
        _day = _day - day;
        return *this;
    }

    Date Date::operator++(int)
    {
        Date temp = *this;
        temp += 1;
        return temp;
    }
    Date Date::operator++()
    {
        *this += 1;
        return *this;
    }

    Date Date::operator--(int)
    {
        Date temp = *this;
        temp += 1;
        return temp;
    }
    Date Date::operator--()
    {
        *this += 1;
        return *this;
    }

    int Date::operator-(const Date &d) const
    {
        int cnt = 0;
        Date temp = d;
        while(*this != temp) {
            temp++;
            cnt++;
        }
        return cnt;
    }